﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
//===
using DevComponents;
using DevComponents.DotNetBar;
using demo2.module.ket_hon;
using demo2.module.xac_nhan_tinh_trang_hon_nhan;
using demo2.module.Khai_tu;
using demo2.module.con_nuoi;
using demo2.module.giam_ho;
using demo2.module.nhan_con;
using demo2.module.QD_cai_chinh;
//using System.Collections;

namespace So_Tu_Phap
{
    public partial class trang_chu : Form
    {

        khai_sinh frm_khaisinh = null;
        ket_hon frm_kethon = null;
        xac_nhan_tinh_trang_hon_nhan frm_xacnhantinhtranghonnhan = null;
        khai_tu frm_khaitu = null;
        con_nuoi frm_connuoi = null;
        giam_ho frm_giamho = null;
        nhan_con frm_nhancon = null;
        qd_cai_chinh frm_qdcaichinh = null;

        public trang_chu()
        {
            InitializeComponent();
            loaddata();
        }

        private void loaddata()
        {
            this.CenterToScreen();
            this.WindowState = FormWindowState.Maximized;
            this.panel3.Visible = false;
        }
        private bool ktra(string nameOfTab)
        {
            foreach (TabItem ttp in tabControl1.Tabs)
            {
                if (ttp.Name == nameOfTab)
                {
                    tabControl1.SelectedTab = ttp;
                    return true;
                }
            }
            return false;
        }
        private void tabControl1_TabItemClose(object sender, TabStripActionEventArgs e)
        {
            TabItem t = tabControl1.SelectedTab;
            tabControl1.Tabs.Remove(t);
            frm_khaisinh = null;
            frm_kethon = null;
            frm_xacnhantinhtranghonnhan = null;
            frm_khaitu = null;
            frm_connuoi = null;
            frm_giamho = null;
            frm_nhancon = null;
            frm_qdcaichinh = null;
        }
        private void Form1_Load(object sender, EventArgs e)
        {

        }
        #region [Click]
        private void menu_khaisinh_Click(object sender, EventArgs e)
        {
            panel3.Visible = true;
            if (frm_khaisinh == null || frm_khaisinh.IsDisposed == true)
            {
                TabItem t = tabControl1.CreateTab("Hồ sơ khai sinh");
                frm_khaisinh = new khai_sinh();
                frm_khaisinh.TopLevel = false;
                frm_khaisinh.Dock = DockStyle.Fill;
                t.AttachedControl.Controls.Add(frm_khaisinh);
                frm_khaisinh.Show();
                tabControl1.SelectedTabIndex = tabControl1.Tabs.Count - 1;
            }
            else
            {
                frm_khaisinh.Activate();
            }
        }
        private void menu_kethon_Click(object sender, EventArgs e)
        {
            panel3.Visible = true;
            if (frm_kethon == null || frm_kethon.IsDisposed == true)
            {
                TabItem t = tabControl1.CreateTab("Hồ sơ kết hôn");
                frm_kethon = new ket_hon();
                frm_kethon.TopLevel = false;
                frm_kethon.Dock = DockStyle.Fill;
                t.AttachedControl.Controls.Add(frm_kethon);
                frm_kethon.Show();
                tabControl1.SelectedTabIndex = tabControl1.Tabs.Count - 1;
            }
            else
            {
                frm_kethon.Activate();
            }
        }
        private void menu_xacnhantinhtranghonnhan_Click(object sender, EventArgs e)
        {
            panel3.Visible = true;
            if (frm_xacnhantinhtranghonnhan == null || frm_xacnhantinhtranghonnhan.IsDisposed == true)
            {
                TabItem t = tabControl1.CreateTab("Xác nhận tình trạng hôn nhân");
                frm_xacnhantinhtranghonnhan = new xac_nhan_tinh_trang_hon_nhan();
                frm_xacnhantinhtranghonnhan.TopLevel = false;
                frm_xacnhantinhtranghonnhan.Dock = DockStyle.Fill;
                t.AttachedControl.Controls.Add(frm_xacnhantinhtranghonnhan);
                frm_xacnhantinhtranghonnhan.Show();
                tabControl1.SelectedTabIndex = tabControl1.Tabs.Count - 1;
            }
            else
            {
                frm_xacnhantinhtranghonnhan.Activate();
            }
        }
        private void menu_khaitu_Click(object sender, EventArgs e)
        {
            panel3.Visible = true;
            if (frm_khaitu == null || frm_khaitu.IsDisposed == true)
            {
                TabItem t = tabControl1.CreateTab("Khai tử");
                frm_khaitu = new khai_tu();
                frm_khaitu.TopLevel = false;
                frm_khaitu.Dock = DockStyle.Fill;
                t.AttachedControl.Controls.Add(frm_khaitu);
                frm_khaitu.Show();
                tabControl1.SelectedTabIndex = tabControl1.Tabs.Count - 1;
            }
            else
            {
                frm_khaitu.Activate();
            }
        }
        private void menu_connuoi_Click(object sender, EventArgs e)
        {
            panel3.Visible = true;
            if (frm_connuoi == null || frm_connuoi.IsDisposed == true)
            {
                TabItem t = tabControl1.CreateTab("Con nuôi");
                frm_connuoi = new con_nuoi();
                frm_connuoi.TopLevel = false;
                frm_connuoi.Dock = DockStyle.Fill;
                t.AttachedControl.Controls.Add(frm_connuoi);
                frm_connuoi.Show();
                tabControl1.SelectedTabIndex = tabControl1.Tabs.Count - 1;
            }
            else
            {
                frm_connuoi.Activate();
            }
        }
        private void menu_giamho_Click(object sender, EventArgs e)
        {
            panel3.Visible = true;
            if (frm_giamho == null || frm_giamho.IsDisposed == true)
            {
                TabItem t = tabControl1.CreateTab("Giám hộ");
                frm_giamho = new giam_ho();
                frm_giamho.TopLevel = false;
                frm_giamho.Dock = DockStyle.Fill;
                t.AttachedControl.Controls.Add(frm_giamho);
                frm_giamho.Show();
                tabControl1.SelectedTabIndex = tabControl1.Tabs.Count - 1;
            }
            else
            {
                frm_giamho.Activate();
            }
        }
        private void menu_nhancon_Click(object sender, EventArgs e)
        {
            panel3.Visible = true;
            if (frm_nhancon == null || frm_nhancon.IsDisposed == true)
            {
                TabItem t = tabControl1.CreateTab("HỒ SƠ NHẬN CHA, MẸ, CON");
                frm_nhancon = new nhan_con();
                frm_nhancon.TopLevel = false;
                frm_nhancon.Dock = DockStyle.Fill;
                t.AttachedControl.Controls.Add(frm_nhancon);
                frm_nhancon.Show();
                tabControl1.SelectedTabIndex = tabControl1.Tabs.Count - 1;
            }
            else
            {
                frm_nhancon.Activate();
            }
        }
        private void menu_caichinh_Click(object sender, EventArgs e)
        {
            panel3.Visible = true;
            if (frm_qdcaichinh == null || frm_qdcaichinh.IsDisposed == true)
            {
                TabItem t = tabControl1.CreateTab("Cải chính");
                frm_qdcaichinh = new qd_cai_chinh();
                frm_qdcaichinh.TopLevel = false;
                frm_qdcaichinh.Dock = DockStyle.Fill;
                t.AttachedControl.Controls.Add(frm_qdcaichinh);
                frm_qdcaichinh.Show();
                tabControl1.SelectedTabIndex = tabControl1.Tabs.Count - 1;
            }
            else
            {
                frm_qdcaichinh.Activate();
            }
        }
        #endregion
    }
}
